package com.ys.dto;

import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class RowClickGridConfigDto {
	private Long rowClickGridId;
	private String pathRequest; // 数据请求地址
	private String colArr;
//	private List<ButtonDto> buttonArr; // 按钮数组

	public String getColArr() {
		return colArr;
	}

	public void setColArr(String colArr) {
		this.colArr = colArr;
	}

	@Data
	@AllArgsConstructor
	public static class ColDto {
		private Long id; // 子列表字段ID
		private String title; // 字段名称
		private String field; // 字段编码
		private String type; // 类型
		private boolean hide; // 是否隐藏
		private String width; // 宽度
		private String align; // 对齐方式
		private String modalRelativeCode;
		private String modalValueCode;
		private String dictKeyBase; // 下拉选项KEY
		private String modalKey; // 弹出框KEY
		private String templet; // 自定义的模板
		private Integer stateEdit; // 是否可编辑
		private Integer multyFileSourceType; // 多文件来源类型
		private boolean unresize; // 是否拉伸
		
		@Override
		public String toString() {
			StringBuffer sb = new StringBuffer();
			if (id != null) {
				sb.append("id:'" + id + "'");
			}
			if(sb.length() > 0)sb.append(",");
			if (title != null && title.length() > 0) {
				sb.append("title:'" + title + "'");
			} else {
				sb.append("title:''");
			}
			if (field != null && field.length() > 0) {
				sb.append(",field:'" + field + "'");
			}
			if (type != null && type.length() > 0) {
				sb.append(",type:'" + type + "'");
			}
			if (hide == true) {
				sb.append(",hide:" + hide + "");
			}
			sb.append(",unresize:" + unresize + "");
			//sb.append(",unresize:true");
			if (width != null && width.length() > 0) {
				sb.append(",width:'" + width + "'");
			}
			if (align != null && align.length() > 0) {
				sb.append(",align:'" + align + "'");
			}
			if (templet != null && templet.length() > 0) {
				if (templet.startsWith("function")) {
					sb.append(",templet:" + templet);
				} else {
					sb.append(",templet:'" + templet + "'");
				}
			}
			StringBuffer res = new StringBuffer("{").append(sb).append("}");
			return res.toString();
		}
	}

	@Data
	@AllArgsConstructor
	public static class ButtonDto {
		private String name; // 名称
		private String event; // 事件
		private String icon; // 图标
		private String style; // 样式类名，如：ys-grid-btn-add
	}

	@Data
	@AllArgsConstructor
	public static class TempletDto {
		private String id; // 模板ID
		private String html; // TPL脚本
	}
}
